public class HomeWork08_06{
    public static void main(String[] args){
        YangHui yh = new YangHui();
        yh.printYangHui(6);
    }
}       

class YangHui{
    public void printYangHui(int line){
        int[][] yanghuiArr = new int[line][];   //构造变长二维数组，存储杨辉三角
        yanghuiArr[0] = new int[1];             //第一行长度1
        yanghuiArr[0][0] = 1;                   
        
        //从第二行开始，构造每一行。其中1由0和1组成
        for(int i = 1; i < line; i++){
            yanghuiArr[i] = new int[i + 1];
            
            int m = 0;
            int n = 0;
            for(int j = 0; j < i; j++){
                m = n;
                n = yanghuiArr[i - 1][j];
                yanghuiArr[i][j] = m + n;
            }
            yanghuiArr[i][i] = 1;
        }
        
        for(int i = 0; i < line; i++){
            for(int j = 0; j <= i; j++){
                System.out.print(yanghuiArr[i][j] + " ");
            }
            System.out.println();
        }
    }
} 